<template>
  <div>
    <city-header></city-header>
    <city-search></city-search>
    <city-list :citys="citys" :hotCitys="hotCitys"></city-list>
    <city-alphabet :citys="citys"></city-alphabet>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data  () {
    return {
      citys: {},
      hotCitys: []
    }
  },
  methods: {
    getCitysInfo () {
      axios.get('/api/city.json').then(this.getCitysInfoResp)
    },
    getCitysInfoResp  (res) {
      res = res.data
      if (res.ret && res.data) {
        const resp = res.data
        this.citys = resp.cities
        this.hotCitys = resp.hotCities
      }
    }
  },
  mounted () {
    this.getCitysInfo()
  }
}
</script>

<style type="stylus" scoped>
</style>
